package com.itheima.job5;

class LuckDraw{
    private int peopleNum = 0;
    public void getDoubleColor(){
        Thread thread = Thread.currentThread();
        String name = thread.getName();
        int count =0;
        try {
            Thread.sleep(50);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        while(true) {
            if (peopleNum<100) {
                peopleNum++;
                count ++;
                String random = DoubleColorBallUtil.create();
                System.out.println("编号为:"+peopleNum+" 的员工 从" + name + "入场! 拿到的双色球彩票号码是:" + random);
            }else{
                System.out.println("结束");
                break;


            }
        }
        System.out.println("从"+name+"进入的人数是"+count+"个");
    }
}

public class Test {
    public static void main(String[] args) {
        LuckDraw luckDraw = new LuckDraw();
        Thread frontDoor = new Thread(
                () -> {
                    luckDraw.getDoubleColor();
                }
        );
        frontDoor.setName("前门");
        frontDoor.start();
        Thread behindDoor = new Thread(
                () -> {
                    luckDraw.getDoubleColor();
                }
        );
        behindDoor.setName("后门");
        behindDoor.start();


    }
}
